package com.rockcent.mall.lib.repository;

import com.rockcent.mall.lib.domain.SysMessageUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

/**
 * Created by zhangjh on 2017/5/27.
 */
@Repository
public interface SysMessageUserRepository extends JpaRepository<SysMessageUser, Long>, JpaSpecificationExecutor {


    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value = "update sys_message_user p set p.status =?1 where p.id = ?2 and user_id= 3?", nativeQuery = true)
    int updateStatusByIdAndUserId(String status, Long id, Long userId);


    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(value = "update sys_message_user p set p.is_delete =?1 where p.id = ?2 and user_id= 3?", nativeQuery = true)
    void updateIsDeleteByIdAndUserId(String isDelete, Long id, Long userId);
}
